package com.cheea.associationBss.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

@SuppressWarnings("serial")
public class User extends Model<User>{
	public static final User dao = new User();
    // 用户登录
    public User login(String uname, String pwd){
        return dao.findFirst("select * from user where uname = ? and pwd = ? limit 1", uname, pwd);
    }
    
    
    // 查询用户的列表
    public List<User> queryListById(int id){
        return dao.find("select u.id,u.uname,u.email,u.createTime from user u where u.belongs = ? ", id);
    }
    
    //管理员查询用户的列表
    public List<User> queryListByAll(){
        return dao.find("select u.id,u.uname,u.email,u.createTime,if(u.role=1, '管理员',if(u.role=2,'社团管理', if(u.role =3, '普通会员', '其他')))as role,u.nickname from user u  where u.role <> 1");
    }
}
